function highAdLayout(w,h){
  $('#articleMain').addClass('ad'+w+'x'+h);
} 

var openTimePopup = function(options){
	var initFn = null;
	var settings = $.extend({
	trigger:$(this),
	url	: null,
	name : '',
	height : 600,
	width : 600,
	popupOptions : 'toolbar=0,scrollbars=1,location=1,statusbar=1,menubar=0,resizable=1'
	}, options);
	if(settings.initFn){settings.initFn();}
    settings.url = settings.url ? settings.url : settings.trigger.attr('href');  
    settings.popupOptions +=',width='+settings.width+',height='+settings.height+',left = '+(screen.width - settings.width) / 2+',top ='+(screen.height - settings.height) / 2;
	newwindow = window.open(settings.url,settings.name,settings.popupOptions);
	if (window.focus) {newwindow.focus();}
};

var slideTimeDropDown = function(options,thisObj){
	var $this = $(thisObj);
	var $thisParent = $this.parent();
	var showFn = function() {
			settings.content.slideDown(settings.animSpeed, function() {
			settings.triggerParent.addClass(settings.cssOpened);
			});
	};
	var hideFn = function() {
			settings.content.slideUp(settings.animSpeed, function(){
			settings.triggerParent.removeClass(settings.cssOpened);
		});
	};
	var initFn = null;
	var settings = $.extend({
	trigger : $this,
	triggerParent : $this.parent(),
	content : $thisParent.find('ul:first'),
	hideFn : hideFn,
	showFn : showFn,
	initFn : initFn,
	animSpeed : 'fast',
	cssOpened : 'opened',
	hoverSpeed : 2000
	}, options);
	if(settings.initFn){settings.initFn();}
	
	if (settings.triggerParent.hasClass(settings.cssOpened)) {
		settings.hideFn();
	} 
	else {
		settings.showFn();
		var t;
		settings.triggerParent.hover(function(){clearTimeout(t);},function(){t = setTimeout(settings.hideFn,settings.hoverSpeed);});
		}
};

(function(){
  $('.articleTools2 .facebook a').live('click',function(e){
    e.preventDefault();
    openTimePopup({trigger:$(this),name:'Facebook',height : 436, width: 800});
  });
  $('.articleTools2 .emailThis a').live('click',function(e){
    e.preventDefault();
    openTimePopup({trigger:$(this),name:'Email This',height : 730, width: 750});
  });
  var ord=Math.random()*10000000000000000;  
  var bubAd = $('<div class="bubAd"><div class="sponsoredAd"><a href="http://ad.doubleclick.net/jump/3475.tim/;sz=130x80;ord='+ord+'?" target="_blank"><img src="http://ad.doubleclick.net/ad/3475.tim/;sz=130x80;ord='+ord+'?" /></a></div></div>');
  $('.articleTools2 .print a').live('mouseover',function(){	
			if($(this).offsetParent().find('.bubAd').length === 0){
				$(this).offsetParent().append(bubAd);
			}
			bubAd.fadeIn();
  });
  $('.articleTools2 .print a').live('mouseout',function(){
    if($(this).offsetParent().find('.bubAd').length > 0){
      bubAd.fadeOut(8000);
     }
  });  
  $('.articleTools2 .email a').live('click',function(e){
    e.preventDefault();
    openTimePopup({trigger:$(this),name:'eMail',height : 630, width: 675});
  });
  $('.articleTools2 .reprints a').live('click',function(e){
    e.preventDefault();
    openTimePopup({trigger:$(this),name:'Reprints',height : 550, width: 695});
  });
  $('#emailWriter').live('click',function(e){
    e.preventDefault();
    openTimePopup({trigger:$(this),name:'Letter',height : 420, width: 400});
  });
  $('#nl2').live('click',function(e){
    e.preventDefault();
    openTimePopup({trigger:$(this),name:'Newsletter',height : 730, width: 550});
  });  
  $('#nl1').live('click',function(e){
    e.preventDefault();
    openTimePopup({trigger:$(this),name:'Newsletter',height : 730, width: 550});
  });
  $('.articleTools2 .typepad a').live('click',function(e){
    e.preventDefault();
    openTimePopup({trigger:$(this),name:'TypePad',height : 730, width: 670});
  });
  $('.articleTools2 .blogger a').live('click',function(e){
    e.preventDefault();
    openTimePopup({trigger:$(this),name:'Blogger',height : 500, width: 750});
  });  
  $('.articleTools2 .livejournal a').live('click',function(ev){ev.preventDefault();																					
  	  var u='http://www.livejournal.com/',
      w=window.open('','','toolbar=0,resizable=1,scrollbars=1,status=1,width=900,height=500');
      if(window.LJ_bookmarklet){
        return LJ_bookmarklet(w,u);
      }
      var e=document.createElement('script');
      e.setAttribute('type','text/javascript');
      e.onload=function(){
        LJ_bookmarklet(w,u);
      };
      e.setAttribute('src',u+'js/bookmarklet.js');
      document.getElementsByTagName('head').item(0).appendChild(e); 
      return false;
  });
    var addTimeInit = function(){
    var trigger = this.trigger,
        $trigger = $(trigger),
        triggerClass = $trigger.attr('class');
    triggerClass = triggerClass ? triggerClass+' ' : '';
    $trigger.hover(function(){
      $trigger.attr('class',triggerClass+'mousein');
    },function(){
      $trigger.attr('class',triggerClass+'mouseout');
    }			
    );
  };
	$('#addTime h4').live('click', function(e){
    e.preventDefault();
    slideTimeDropDown({initFn:addTimeInit},this);
    e.stopPropagation();
  });
  $('.socialTools .more h4').live('click', function(e){
    e.preventDefault();
    slideTimeDropDown({},this);
    e.stopPropagation();
  });
})();

$(function(){
	(function(){
		var tb1 = $("#tabChange1");
		var tb2 = $("#tabChange2");
		tb1.bind("click keydown keypress", function(){
		changeMultimediaTab(1);
		return false;
		 });
		tb2.bind("click keydown keypress", function(){
		changeMultimediaTab(2);
		return false;		
		});	
		function changeMultimediaTab(num) {
			$("#tab1, #tab2").attr("class", "off");
			$("#tabContent1, #tabContent2").attr("class", "off");
			$("#tab"+num).attr("class", "");
			$("#tabContent"+num).attr("class", "");
		}
	})();
	
(function(){
var $moreNews = $('#moreNews');
if($moreNews.length){
  var partnerModArr = {
    'nation' : [{'feedLink':'/time/includes/rssfeeds/rottentomato.txt',
              'partner':'RottenTomatoes',
              'siteLink' : 'http://www.rottentomatoes.com'}
             ],
    'world' : [{'feedLink':'/time/includes/rssfeeds/rottentomato.txt',
              'partner':'RottenTomatoes',
              'siteLink' : 'http://www.rottentomatoes.com'}
             ],
    'politics' : [{'feedLink':'/time/includes/rssfeeds/rottentomato.txt',
              'partner':'RottenTomatoes',
              'siteLink' : 'http://www.rottentomatoes.com'}
             ],
    'biz/tech' : [{'feedLink':'/time/includes/rssfeeds/rottentomato.txt',
              'partner':'RottenTomatoes',
              'siteLink' : 'http://www.rottentomatoes.com'}
             ],
    'arts' : [{'feedLink':'/time/includes/rssfeeds/life.txt',
              'partner':'Life',
              'siteLink' : 'http://www.life.com'},
              {'feedLink':'/time/includes/rssfeeds/si.txt',
              'partner':'Si',
              'siteLink' : 'http://www.si.com'}
             ],
   'sci/health' :[{'feedLink':'/time/includes/rssfeeds/life_health.txt',
              'partner':'Life',
              'siteLink' : 'http://www.life.com'},
              {'feedLink':'/time/includes/rssfeeds/si.txt',
              'partner':'Si',
              'siteLink' : 'http://www.si.com'}
             ],
   'travel' :[{'feedLink':'/time/includes/rssfeeds/si.txt',
              'partner':'Si',
              'siteLink' : 'http://www.si.com'}
             ],
    'default' : [{'feedLink':'/time/includes/rssfeeds/rottentomato.txt',
              'partner':'RottenTomatoes',
              'siteLink' : 'http://www.rottentomatoes.com'}
             ]                          
  },
  partnerMod = partnerModArr[s_time.prop6] ? partnerModArr[s_time.prop6] : partnerModArr['default'];
   var mod = partnerMod[Math.floor(Math.random()*partnerMod.length)],
      feedLink = mod.feedLink,
      siteLink = mod.siteLink,
      partner = mod.partner;
	 $.get(feedLink, function(data, textStatus){
     $('#moreNews').append('<div class="col partner'+partner+'Col"><h4><a href="'+siteLink+'" target="_blank" class="partner'+partner+'">'+partner+' News</a></h4>'+data+'</div>');
    });      
}
})();

$Launchpad.CreateMenu({ wid : "491cae4a5db36d0d", actionElement : "myWidget",servicesInclude: ['facebook','yahoo','email','google','live','myspace','netvibes', 'wordpress', 'digg','embed'] });
});